﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using hachiModel;

public partial class ProductList : System.Web.UI.Page
{
    Hachi.Controllers.CategoriesController cctr = new Hachi.Controllers.CategoriesController();
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string lang = Session["Lang"] == null ? hachiCookies.getCookieValue("Lang") : Session["Lang"].ToString();
            string alias = Request.QueryString["a"].Replace("â", "⁄");

            PR_Category c = cctr.getCategory(alias, lang);
            PR_CategoryDetail cd = cctr.getCategoryDetail(c.CategoryID, lang);
            PR_CategoryDetail pc = c.ParentID != null ? cctr.getCategoryDetail(c.ParentID.Value, lang) : null;

            if (c != null && cd != null)
            {
                if (pc != null)
                {
                    lblPageTitle.Text = cd.CategoryName + " | " + pc.CategoryName;
                    lblCateName.Text = "<a href='" + (new UriBuilder(Request.Url.Scheme, Request.Url.Host, Request.Url.Port)).ToString() + pc.Alias + "'>" + pc.CategoryName + "</a> > " + cd.CategoryName;
                }
                else
                    lblPageTitle.Text = lblCateName.Text = cd.CategoryName;
                ltrInitScript.Text = "<script>var cCategoryID = " + c.CategoryID + "; $(document).ready(function (){loadAllPage(" + c.CategoryID + ");});</script>";
            }

        }
        catch (Exception ex)
        {
            lblPageTitle.Text = lblCateName.Text = Request.QueryString["a"] + ex.Message;
            //<meta itemprop="name" content="Title of your content">
            //<meta itemprop="description" content="This would be a description of the content your users are sharing">
        }
        


    }
}